import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/model/tab_bar_data_model.dart';
import 'package:ls_work/res/colors.dart';

import 'my_service_order_list_fragment.dart';

class MyServiceOrderHomePage extends BaseStatefulMvvmWidget {
  @override
  State<StatefulWidget> createState() => _MyServiceOrderHomeState();
}

class _MyServiceOrderHomeState
    extends BaseMvvmState<CommonViewModel, MyServiceOrderHomePage> {
  List<TabBarDataModel> get titles => [
        TabBarDataModel(title: "未完成", id: "333"),
        TabBarDataModel(title: "已完成", id: "10242")
      ];

  @override
  Widget buildLoadingContentView() {
    return DefaultTabController(
        length: titles.length,
        child: Column(
          children: [
            Material(
              color: Colors.white,
              child: PreferredSize(
                child: TabBar(
                  tabs: titles
                      .map((e) => Tab(
                            text: e.title,
                          ))
                      .toList(),
                  indicator: BoxDecoration(),
                  unselectedLabelColor: Color(0xff95989D),
                  labelColor: Colours.app_main,
                  labelStyle:
                      TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
                  unselectedLabelStyle:
                      TextStyle(fontWeight: FontWeight.normal, fontSize: 13),
                ),
                preferredSize: Size.fromHeight(35),
              ),
            ),
            TabBarView(
              children:
                  titles.map((e) => MyServiceOrderListFragment(e.id!)).toList(),
            ).setWeight(1)
          ],
        ));
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return loadingContentWidget;
  }

  @override
  CommonViewModel createViewModel() {
    return CommonViewModel(context);
  }

  @override
  void onRetryClick() {
    // TODO: implement onRetryClick
  }
}
